//
// Created by bjliuyong on 2021/7/11.
//

#ifndef JVM_GLOBALDEFINITIONS_H
#define JVM_GLOBALDEFINITIONS_H

#include <string>
#include "memory/mempool/memory_pool.h"

typedef unsigned long long uint64_t;

//----------------------------------------------------------------------------------------------------
// Additional Java basic types

typedef unsigned char    jubyte;
typedef unsigned short   jushort;
typedef unsigned int     juint;
typedef uint64_t julong;
typedef double jdouble;

typedef int8_t jbyte;
typedef int16_t jshort;
typedef int64_t  jlong;


//----------------------------------------------------------------------------------------------------
// Java type definitions

// All kinds of 'plain' byte addresses
typedef   signed char s_char;
typedef unsigned char u_char;
typedef u_char*       address;



// Unsigned byte types for os and stream.hpp

// Unsigned one, two, four and eigth byte quantities used for describing
// the .class file format. See JVM book chapter 4.

typedef jubyte  u1;
typedef jushort u2;
typedef juint   u4;
typedef julong  u8;

typedef jbyte  s1;
typedef jshort s2;
typedef jlong  s8;

const int LogBytesPerWord    = 3;
const int BytesPerWord       = 1 << LogBytesPerWord;


class MetaWord {

private:
    MemoryCell* cell ; 


public:
    MetaWord(MemoryCell* cell){
        this->cell = cell;
    }

    int value() {
        return *((int*)cell->ptr());
    }

    void* ptr(){
        return this->cell->ptr();
    }
};


// Analogous opaque struct for metadata allocated from metaspaces.
//class MetaWordImpl;             // Opaque, never defined.
//typedef MetaWordImpl* MetaWord;

#endif //JVM_GLOBALDEFINITIONS_H
